import request from '@u/request'
// 获取商品列表
const fetchItems = (params = {}) => (
  request.post('/shop/goods/list/v2', params)
)
// 首页轮播
const fetchHomeBanner = (params = {}) => {
  return request.get('/banner/list', { params })
}
// 获取商品详情
const fetchItemDetail = (params = {}) => {
  return request.get('/shop/goods/detail', { params })
}
// 获取商品分类
const fetchCates = (params = {}) => {
  return request.get('/shop/goods/category/all', { params })
}
// 用户注册
const userReg = (params = {}) => (
  request.post('/user/username/register', params)
)
// 用户登录
const userLogin = (params = {}) => (
  request.post('/user/username/login', params)
)
// 加入购物车 /shopping-cart/add
const addItemToCart = (params = {}) => (
  request.post('/shopping-cart/add', params)
)
// 获取购物车数据 /shopping-cart/info
const fetchCartInfo = (params = {}) => {
  return request.get('/shopping-cart/info', { params })
}
// 修改购物车商品 数量 /shopping-cart/modifyNumber
const modifyCartItemNum =  (params = {}) => (
  request.post('/shopping-cart/modifyNumber', params)
)
// 修改购物车商品选中状态
const modifyCartItemSelected =  (params = {}) => (
  request.post('/shopping-cart/select', params)
)
// 删除购物车中的商品 /shopping-cart/remove
const removeCartItem =  (params = {}) => (
  request.post('/shopping-cart/remove', params)
)
export {
  fetchItems,
  fetchHomeBanner,
  fetchItemDetail,
  fetchCates,
  userReg,
  userLogin,
  addItemToCart,
  fetchCartInfo,
  modifyCartItemNum,
  modifyCartItemSelected,
  removeCartItem
}